package com.sunnada.edu.system.sysuser.service;

import java.util.HashMap;
import java.util.List;

import com.sunnada.edu.system.pub.common.AppContext;
import com.sunnada.edu.system.pub.common.MD5;
import com.sunnada.edu.system.pub.dao.PubDao;
import com.sunnada.edu.system.pub.util.Utils;

public class SysUserMethods {

	public static int restPwd(HashMap<String, String> params) {
		PubDao dao = AppContext.getInstance().getPubDao();
		String userId = params.get("userId");
		String password = params.get("password");
		password = MD5.md5(userId + password);
		String sql = "update S_SYSUSER set  LOGIN_PWD='" + password + "' where USER_ID='" + userId + "'";
		int num = dao.update(sql);
		return num;

	}

	public static int getSysUserCotByPhone(HashMap<String, String> params) {
		PubDao dao = AppContext.getInstance().getPubDao();
		String phone = params.get("phone");
		String userId = params.get("recId");
		String sql = "select t.* from S_SYSUSER t where  (t.phone='" + phone + "' or t.USER_LOGINCODE='" + phone
				+ "') and rec_status!='2' ";
		if (Utils.isNotNull(userId)) {
			sql += " and t.user_id !='" + userId + "'";
		}
		return dao.selectListCot(sql);
	}

}
